package eval.deploy;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import eval.host.Host;
import eval.vm.VirtualMachine;

/**
 * Generates and stores the history of deploys in the cloud infrastructure
 * 
 * @author Nicola Calcavecchia <calcavecchia@elet.polimi.it>
 * @author Amit Peled   <amit.kapina@gmail.com>
 * @author Igal Kaufman <igal.kaufman@gmail.com>
 */
public interface IDeployManager extends Serializable {

	/**
	 * Returns the set of VMs to be deployed at cycle <code>cycle</code>
	 * 
	 * @param tick
	 * @return a set of VM associate to tick
	 */
	public DeploySet getDeploySetAtTick(int tick);

	/**
	 * Returns a list containing all the Virtual Machines that need to be
	 * removed at the given cycle
	 *
	 * @param tick
	 * @param vmMapping the map of current placement
	 * @return list of VMs to be remove
	 */
	public List<VirtualMachine> getVMToBeRemovedAtTick(int tick, Map<Host, List<VirtualMachine>> vmMapping);

	/**
	 * Returns a list containing all the Virtual Machines that need to be
	 * removed at the given cycle
	 * 
	 * @param tick
	 * @param vmList list of VMs 
	 * @return list of VMs to be remove
	 */
	public List<VirtualMachine> getVMToBeRemovedAtTick(int tick,List<VirtualMachine> vmList);

	/**
	 * check if we have VM to be remove at tick
	 * 
	 * @param virtualMachine
	 * @param tick
	 * @return true if their is VM to be removed at the given cycle, false otherwise
	 */
	public boolean isVMRemovedAtTick(VirtualMachine virtualMachine, int tick);

	/**
	 * Adds the given deploy set at the given tick
	 * 
	 * @param deployset
	 * @param tick
	 */
	public void setDeploySetAtTick(DeploySet deployset, int tick);

	/**
	 * Set the cycle when the virtual machine was deploy
	 * 
	 * @param vm The virtual machine to deploy
	 * @param cycle The experiment tick
	 */
	public void setVmStartLife(VirtualMachine vm,int cycle);

	/**
	 * estimate average live time of VM
	 * @return the estimate life time of VM
	 */
	public double getEstimatedAverageLifeTime();

}
